package com.klikmee.sms.core.web.service;

import com.klikmee.sms.core.base.dao.ClientDAO;
import com.klikmee.sms.core.model.Client;

public class LoginService {

	private ClientDAO	clientDAO	= null;

	/**
	 *  
	 * @param username
	 * @param password
	 * @return 0 if login succeeded, 1 if username doesnt exist, 2 if username is ok but wrong pass.
	 */
	public Client login( String username, String password ) {

		// find client with given username
		Client client = this.clientDAO.findByUsername( username );

		if (client != null) {
			// test if username and pass match
			if (client.getPassword().equals( password )) {
				return client;
			}
		}

		return null;

	}
	
	

	public ClientDAO getClientDAO() {
		return clientDAO;
	}

	public void setClientDAO( ClientDAO clientDAO ) {
		this.clientDAO = clientDAO;
	}

}
